<?php
if(file_exists("config.php")) {include("config.php");}
include("inc/func.php");
include("db.php");
header("Content-Type: application/xml; charset=ISO-8859-1"); 
global $db_prefix;
$query = "SELECT value FROM `$db_prefix"."main` WHERE `option` = 'title'";
$result = mysql_query($query);
while($row2 = mysql_fetch_row($result)) { 
	$title = $row2[0]; 
}
$query2 = "SELECT value FROM `$db_prefix"."main` WHERE `option` = 'subtitle'";
$result2 = mysql_query($query2);
while($row1 = mysql_fetch_row($result2)) { 
	$subtitle = $row1[0]; 
}
$limitquery = "SELECT value FROM `".$db_prefix."main` WHERE `option` = 'postlimit'";
$limitresult = mysql_query($limitquery);
$limit = mysql_fetch_row($limitresult);
$url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$url = str_replace("/feed.php",'',$url);
ec('<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
<title>'.$title.'</title>
<description>'.$subtitle.'</description>
<link>'.$url.'</link>
<pubDate>'.date(r).'</pubDate>
<generator>http://nothingconcept.com/bazooka?v=1.15</generator>');
$postquery  = "SELECT * FROM ".$db_prefix."posts ORDER BY id DESC LIMIT 0, $limit[0];";
$postresult = mysql_query($postquery) or die('Error!');
if(mysql_num_rows($postresult) == 0) {echo("Nothing to Display!");}
else {
	while($postrow = mysql_fetch_row($postresult)) {
	$id = $postrow[0];
	$title = $postrow[1];
	$author = $postrow[2];
	$date = $postrow[3];
	$type = $postrow[4];
	$text = $postrow[5];
	$title = strip_tags($title);
	$text = strip_tags($text);
	ec("
	<item>
	<title>[$type]");
	if(empty($title)) {ec(" - $text");}
	else {ec(" - $title");}
	ec("</title>
	<link>$url/?id=$id</link>
	<guid>$url/?id=$id</guid>
	<description>$text</description>
	<date>$date</date>");
	if(empty($author)) {}
	else { ec("
	<author>$author</author>"); }
	ec("
	</item>
	");
	}
}
?>
</channel>
</rss>